package servlet.rool;

import pojo.Admin;
import pojo.Role;
import service.AdminService;
import service.RoleService;
import service.impl.AdminServiceImpl;
import service.impl.RoleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 修改前的回显的servlet
 */
@WebServlet(value = "/AdminEchoServlet")
public class AdminEchoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ID=request.getParameter("ID");
        AdminService as=new AdminServiceImpl();
        RoleService rs=new RoleServiceImpl();
        Role role=rs.queryOneRole(Integer.parseInt(ID));
        Admin admin=as.queryAdmin(Integer.parseInt(ID));
        List<Role> roles=rs.queryAllRole();
        request.setAttribute("admin",admin);
        request.setAttribute("roles",roles);
        request.setAttribute("role",role);
        request.getRequestDispatcher("jsp/yjj/AdminUpdate.jsp").forward(request,response);

    }
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
        doGet(request, response);
    }
}
